package com.ddyx.rest;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ddyx.service.BookingService;
import com.ddyx.util.RequestForm;
import com.ddyx.util.ResponseForm;
import com.mysql.fabric.Response;

@Controller
@RequestMapping("/book")
public class BookingController {
	@Resource
	BookingService bookingService;

	/**
	 * 新增预约单
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping(value = "insertBooking", method = RequestMethod.POST)
	public ResponseForm insertBooking(@RequestBody RequestForm param, HttpServletRequest req) throws Exception {
		return bookingService.insertBooking(param, req);
	}

	/**
	 * 修改预约单
	 */
	@ResponseBody
	@RequestMapping(value = "editBooking", method = RequestMethod.POST)
	public ResponseForm editBooking(@RequestBody RequestForm param, HttpServletRequest req) {
		return bookingService.editBooking(param, req);
	}

	/**
	 * 取消预约单
	 */
	@ResponseBody
	@RequestMapping(value = "cancelBooking", method = RequestMethod.POST)
	public ResponseForm cancelBooking(@RequestBody RequestForm param, HttpServletRequest req) {
		return bookingService.cancelBooking(param, req);
	}

	/**
	 * 根据客户查询预约商品信息列表
	 * 根据门店号查询预约商品信息列表
	 */
	@ResponseBody
	@RequestMapping(value = "getBooking", method = RequestMethod.POST)
	public ResponseForm getBooking(@RequestBody RequestForm param) {
		return bookingService.getBooking(param);
	}

	/**
	 * 用户查看预约详情页
	 */
	@ResponseBody
	@RequestMapping(value = "getBookingDetails", method = RequestMethod.POST)
	public ResponseForm getBookingDetails(@RequestBody RequestForm param) {
		return bookingService.getBookingDetails(param);
	}

	/**
	 * 获取所有已经结束的预约(包含以下四种情况) 1: 未赴约未过期未取消(默认) 0:取消预约(此状态为用户控制)
	 * 2:已赴约(此状态为为店员根据用户赴约情况控制) 3:未赴约已过期(此状态为系统自动控制)
	 */
	@ResponseBody
	@RequestMapping(value = "getOverBooking", method = RequestMethod.POST)
	public ResponseForm getOverBooking(@RequestBody RequestForm param) {
		return bookingService.getOverBooking(param);
	}
	
	/**
	 * 修改预约单状态
	 * 2 : 已赴约
	 * 3 : 未赴约/已过期
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "editBookingStatus",method = RequestMethod.POST )
	public ResponseForm editBookingStatus(@RequestBody RequestForm param) {
		return bookingService.editBookingStatus(param);
	}
	
	/**
	 * 一键预约接口
	 * @param param
	 * @param req
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value="insertBookings" , method= RequestMethod.POST)
	public ResponseForm insertBookings(@RequestBody RequestForm param, HttpServletRequest req){
		return bookingService.insertBookings(param, req);
	}
	
	
}
